{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "导入包"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 101,
   "outputs": [],
   "source": [
    "from xtquant import xtdata"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "订阅单股行情"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取所有股票代码"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [
    "all_stock_list = xtdata.get_stock_list_in_sector(\"沪深A股\")\n",
    "for stock in all_stock_list:\n",
    "    print(stock)\n",
    "all_stock_list"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "is_executing": true
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 103,
   "outputs": [
    {
     "data": {
      "text/plain": "16"
     },
     "execution_count": 103,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def on_data(datas):\n",
    "    for stock_code in datas:\n",
    "        #print(stock_code, datas[stock_code])\n",
    "        stock_code\n",
    "whole_id = xtdata.subscribe_whole_quote(all_stock_list, callback=on_data)\n",
    "whole_id"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "订阅单股行情"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 104,
   "outputs": [
    {
     "data": {
      "text/plain": "17"
     },
     "execution_count": 104,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "def on_quote(data):\n",
    "    print(data)\n",
    "xtdata.subscribe_quote('601777.SH', period='1d', count=0, callback=on_quote)\n",
    "#xtdata.run()"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "取消订阅"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 105,
   "outputs": [],
   "source": [
    "xtdata.unsubscribe_quote(13)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取行情数据"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 116,
   "outputs": [
    {
     "data": {
      "text/plain": "{'time': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'open': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'high': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'low': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'close': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'volume': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'amount': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'settelementPrice': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'openInterest': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'preClose': Empty DataFrame\n Columns: []\n Index: [000606.SZ],\n 'suspendFlag': Empty DataFrame\n Columns: []\n Index: [000606.SZ]}"
     },
     "execution_count": 116,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "market_data = xtdata.get_market_data(stock_list=['000606.SZ'],field_list=[], period='1d', count=1, dividend_type='none', fill_data=False)\n",
    "market_data"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取合约基础信息"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 107,
   "outputs": [
    {
     "data": {
      "text/plain": "{'ExchangeID': 'SZ',\n 'InstrumentID': '000903',\n 'InstrumentName': '云内动力',\n 'ProductID': None,\n 'ProductName': None,\n 'CreateDate': '0',\n 'OpenDate': '19990415',\n 'ExpireDate': 99999999,\n 'PreClose': 2.78,\n 'SettlementPrice': 2.78,\n 'UpStopPrice': 3.06,\n 'DownStopPrice': 2.5,\n 'FloatVolume': 1920261648.0,\n 'TotalVolume': 1970800857.0,\n 'LongMarginRatio': None,\n 'ShortMarginRatio': None,\n 'PriceTick': 0.01,\n 'VolumeMultiple': 1,\n 'MainContract': None,\n 'LastVolume': None,\n 'InstrumentStatus': 0,\n 'IsTrading': None,\n 'IsRecent': None,\n 'ProductTradeQuota': None,\n 'ContractTradeQuota': None,\n 'ProductOpenInterestQuota': None,\n 'ContractOpenInterestQuota': None}"
     },
     "execution_count": 107,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "detail = xtdata.get_instrument_detail('000903.SZ')\n",
    "detail"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取合约类型"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 108,
   "outputs": [
    {
     "data": {
      "text/plain": "{'index': False, 'stock': True, 'fund': False, 'etf': False}"
     },
     "execution_count": 108,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "instrument_type = xtdata.get_instrument_type('000903.SZ')\n",
    "instrument_type"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取交易日列表"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 109,
   "outputs": [
    {
     "data": {
      "text/plain": "[662745600000,\n 662832000000,\n 662918400000,\n 663177600000,\n 663264000000,\n 663350400000,\n 663436800000,\n 663523200000,\n 663782400000,\n 663868800000,\n 663955200000,\n 664041600000,\n 664128000000,\n 664387200000,\n 664473600000,\n 664560000000,\n 664646400000,\n 664732800000,\n 664992000000,\n 665078400000,\n 665164800000,\n 665251200000,\n 665337600000,\n 665596800000,\n 665683200000,\n 665769600000,\n 665856000000,\n 665942400000,\n 666201600000,\n 666288000000,\n 666374400000,\n 666460800000,\n 666892800000,\n 666979200000,\n 667065600000,\n 667152000000,\n 667411200000,\n 667497600000,\n 667584000000,\n 667670400000,\n 667756800000,\n 668016000000,\n 668102400000,\n 668188800000,\n 668275200000,\n 668361600000,\n 668620800000,\n 668707200000,\n 668793600000,\n 668880000000,\n 668966400000,\n 669225600000,\n 669312000000,\n 669398400000,\n 669484800000,\n 669571200000,\n 669830400000,\n 669916800000,\n 670003200000,\n 670089600000,\n 670176000000,\n 670435200000,\n 670521600000,\n 670608000000,\n 670694400000,\n 670780800000,\n 671040000000,\n 671126400000,\n 671212800000,\n 671299200000,\n 671385600000,\n 671644800000,\n 671731200000,\n 671817600000,\n 671904000000,\n 671990400000,\n 672249600000,\n 672336000000,\n 672422400000,\n 672508800000,\n 672595200000,\n 672854400000,\n 672940800000,\n 673113600000,\n 673200000000,\n 673459200000,\n 673545600000,\n 673632000000,\n 673718400000,\n 673804800000,\n 674064000000,\n 674150400000,\n 674236800000,\n 674323200000,\n 674409600000,\n 674668800000,\n 674755200000,\n 674841600000,\n 674928000000,\n 675014400000,\n 675273600000,\n 675360000000,\n 675446400000,\n 675532800000,\n 675619200000,\n 675878400000,\n 675964800000,\n 676051200000,\n 676137600000,\n 676224000000,\n 676483200000,\n 676569600000,\n 676656000000,\n 676742400000,\n 676828800000,\n 677088000000,\n 677174400000,\n 677260800000,\n 677347200000,\n 677433600000,\n 677692800000,\n 677779200000,\n 677865600000,\n 677952000000,\n 678038400000,\n 678297600000,\n 678384000000,\n 678470400000,\n 678556800000,\n 678643200000,\n 678902400000,\n 678988800000,\n 679075200000,\n 679161600000,\n 679248000000,\n 679507200000,\n 679593600000,\n 679680000000,\n 679766400000,\n 679852800000,\n 680112000000,\n 680198400000,\n 680284800000,\n 680371200000,\n 680457600000,\n 680716800000,\n 680803200000,\n 680889600000,\n 680976000000,\n 681062400000,\n 681321600000,\n 681408000000,\n 681494400000,\n 681580800000,\n 681667200000,\n 681926400000,\n 682012800000,\n 682099200000,\n 682185600000,\n 682272000000,\n 682531200000,\n 682617600000,\n 682704000000,\n 682790400000,\n 682876800000,\n 683136000000,\n 683222400000,\n 683308800000,\n 683395200000,\n 683481600000,\n 683740800000,\n 683827200000,\n 683913600000,\n 684000000000,\n 684086400000,\n 684345600000,\n 684432000000,\n 684518400000,\n 684604800000,\n 684691200000,\n 684950400000,\n 685036800000,\n 685123200000,\n 685209600000,\n 685296000000,\n 685555200000,\n 685641600000,\n 685728000000,\n 685814400000,\n 685900800000,\n 686160000000,\n 686419200000,\n 686505600000,\n 686764800000,\n 686851200000,\n 686937600000,\n 687024000000,\n 687110400000,\n 687369600000,\n 687456000000,\n 687542400000,\n 687628800000,\n 687715200000,\n 687974400000,\n 688060800000,\n 688147200000,\n 688233600000,\n 688320000000,\n 688579200000,\n 688665600000,\n 688752000000,\n 688838400000,\n 688924800000,\n 689184000000,\n 689270400000,\n 689356800000,\n 689443200000,\n 689529600000,\n 689788800000,\n 689875200000,\n 689961600000,\n 690048000000,\n 690134400000,\n 690393600000,\n 690480000000,\n 690566400000,\n 690652800000,\n 690739200000,\n 690998400000,\n 691084800000,\n 691171200000,\n 691257600000,\n 691344000000,\n 691603200000,\n 691689600000,\n 691776000000,\n 691862400000,\n 691948800000,\n 692208000000,\n 692294400000,\n 692380800000,\n 692467200000,\n 692553600000,\n 692812800000,\n 692899200000,\n 692985600000,\n 693072000000,\n 693158400000,\n 693417600000,\n 693504000000,\n 693590400000,\n 693676800000,\n 693763200000,\n 694022400000,\n 694108800000,\n 694281600000,\n 694368000000,\n 694627200000,\n 694713600000,\n 694800000000,\n 694886400000,\n 694972800000,\n 695232000000,\n 695318400000,\n 695404800000,\n 695491200000,\n 695577600000,\n 695836800000,\n 695923200000,\n 696009600000,\n 696096000000,\n 696182400000,\n 696441600000,\n 696528000000,\n 696614400000,\n 696700800000,\n 696787200000,\n 697046400000,\n 697392000000,\n 697651200000,\n 697737600000,\n 697824000000,\n 697910400000,\n 697996800000,\n 698256000000,\n 698342400000,\n 698428800000,\n 698515200000,\n 698601600000,\n 698860800000,\n 698947200000,\n 699033600000,\n 699120000000,\n 699206400000,\n 699465600000,\n 699552000000,\n 699638400000,\n 699724800000,\n 699811200000,\n 700070400000,\n 700156800000,\n 700243200000,\n 700329600000,\n 700416000000,\n 700675200000,\n 700761600000,\n 700848000000,\n 700934400000,\n 701020800000,\n 701280000000,\n 701366400000,\n 701452800000,\n 701539200000,\n 701625600000,\n 701884800000,\n 701971200000,\n 702057600000,\n 702144000000,\n 702230400000,\n 702489600000,\n 702576000000,\n 702662400000,\n 702748800000,\n 702835200000,\n 703094400000,\n 703180800000,\n 703267200000,\n 703353600000,\n 703440000000,\n 703699200000,\n 703785600000,\n 703872000000,\n 703958400000,\n 704044800000,\n 704304000000,\n 704390400000,\n 704476800000,\n 704563200000,\n 704908800000,\n 704995200000,\n 705081600000,\n 705168000000,\n 705254400000,\n 705513600000,\n 705600000000,\n 705686400000,\n 705772800000,\n 705859200000,\n 706118400000,\n 706204800000,\n 706291200000,\n 706377600000,\n 706464000000,\n 706723200000,\n 706809600000,\n 706896000000,\n 706982400000,\n 707068800000,\n 707328000000,\n 707414400000,\n 707500800000,\n 707587200000,\n 707673600000,\n 707932800000,\n 708019200000,\n 708105600000,\n 708192000000,\n 708278400000,\n 708537600000,\n 708624000000,\n 708710400000,\n 708796800000,\n 708883200000,\n 709142400000,\n 709228800000,\n 709315200000,\n 709401600000,\n 709488000000,\n 709747200000,\n 709833600000,\n 709920000000,\n 710006400000,\n 710092800000,\n 710352000000,\n 710438400000,\n 710524800000,\n 710611200000,\n 710697600000,\n 710956800000,\n 711043200000,\n 711129600000,\n 711216000000,\n 711302400000,\n 711561600000,\n 711648000000,\n 711734400000,\n 711820800000,\n 711907200000,\n 712166400000,\n 712252800000,\n 712339200000,\n 712425600000,\n 712512000000,\n 712771200000,\n 712857600000,\n 712944000000,\n 713030400000,\n 713116800000,\n 713376000000,\n 713462400000,\n 713548800000,\n 713635200000,\n 713721600000,\n 713980800000,\n 714067200000,\n 714153600000,\n 714240000000,\n 714326400000,\n 714585600000,\n 714672000000,\n 714758400000,\n 714844800000,\n 714931200000,\n 715190400000,\n 715276800000,\n 715363200000,\n 715449600000,\n 715536000000,\n 715795200000,\n 715881600000,\n 715968000000,\n 716054400000,\n 716140800000,\n 716400000000,\n 716486400000,\n 716572800000,\n 716659200000,\n 716745600000,\n 717004800000,\n 717091200000,\n 717177600000,\n 717264000000,\n 717350400000,\n 717609600000,\n 717696000000,\n 717782400000,\n 718214400000,\n 718300800000,\n 718387200000,\n 718473600000,\n 718560000000,\n 718819200000,\n 718905600000,\n 718992000000,\n 719078400000,\n 719164800000,\n 719424000000,\n 719510400000,\n 719596800000,\n 719683200000,\n 719769600000,\n 720028800000,\n 720115200000,\n 720201600000,\n 720288000000,\n 720374400000,\n 720633600000,\n 720720000000,\n 720806400000,\n 720892800000,\n 720979200000,\n 721238400000,\n 721324800000,\n 721411200000,\n 721497600000,\n 721584000000,\n 721843200000,\n 721929600000,\n 722016000000,\n 722102400000,\n 722188800000,\n 722448000000,\n 722534400000,\n 722620800000,\n 722707200000,\n 722793600000,\n 723052800000,\n 723139200000,\n 723225600000,\n 723312000000,\n 723398400000,\n 723657600000,\n 723744000000,\n 723830400000,\n 723916800000,\n 724003200000,\n 724262400000,\n 724348800000,\n 724435200000,\n 724521600000,\n 724608000000,\n 724867200000,\n 724953600000,\n 725040000000,\n 725126400000,\n 725212800000,\n 725472000000,\n 725558400000,\n 725644800000,\n 725731200000,\n 726076800000,\n 726163200000,\n 726249600000,\n 726336000000,\n 726422400000,\n 726681600000,\n 726768000000,\n 726854400000,\n 726940800000,\n 727027200000,\n 727286400000,\n 727372800000,\n 727459200000,\n 727545600000,\n 727632000000,\n 728064000000,\n 728150400000,\n 728236800000,\n 728496000000,\n 728582400000,\n 728668800000,\n 728755200000,\n 728841600000,\n 729100800000,\n 729187200000,\n 729273600000,\n 729360000000,\n 729446400000,\n 729705600000,\n 729792000000,\n 729878400000,\n 729964800000,\n 730051200000,\n 730310400000,\n 730396800000,\n 730483200000,\n 730569600000,\n 730656000000,\n 730915200000,\n 731001600000,\n 731088000000,\n 731174400000,\n 731260800000,\n 731520000000,\n 731606400000,\n 731692800000,\n 731779200000,\n 731865600000,\n 732124800000,\n 732211200000,\n 732297600000,\n 732384000000,\n 732470400000,\n 732729600000,\n 732816000000,\n 732902400000,\n 732988800000,\n 733075200000,\n 733334400000,\n 733420800000,\n 733507200000,\n 733593600000,\n 733680000000,\n 733939200000,\n 734025600000,\n 734112000000,\n 734198400000,\n 734284800000,\n 734544000000,\n 734630400000,\n 734716800000,\n 734803200000,\n 734889600000,\n 735148800000,\n 735235200000,\n 735321600000,\n 735408000000,\n 735494400000,\n 735753600000,\n 735840000000,\n 735926400000,\n 736012800000,\n 736099200000,\n 736358400000,\n 736444800000,\n 736531200000,\n 736617600000,\n 736704000000,\n 736963200000,\n 737049600000,\n 737136000000,\n 737222400000,\n 737308800000,\n 737568000000,\n 737654400000,\n 737740800000,\n 737827200000,\n 737913600000,\n 738172800000,\n 738259200000,\n 738345600000,\n 738432000000,\n 738518400000,\n 738777600000,\n 738864000000,\n 738950400000,\n 739036800000,\n 739123200000,\n 739382400000,\n 739468800000,\n 739555200000,\n 739641600000,\n 739728000000,\n 739987200000,\n 740073600000,\n 740160000000,\n 740246400000,\n 740332800000,\n 740592000000,\n 740678400000,\n 740764800000,\n 740851200000,\n 740937600000,\n 741196800000,\n 741283200000,\n 741369600000,\n 741456000000,\n 741542400000,\n 741801600000,\n 741888000000,\n 741974400000,\n 742060800000,\n 742147200000,\n 742406400000,\n 742492800000,\n 742579200000,\n 742665600000,\n 742752000000,\n 743011200000,\n 743097600000,\n 743184000000,\n 743270400000,\n 743356800000,\n 743616000000,\n 743702400000,\n 743788800000,\n 743875200000,\n 743961600000,\n 744220800000,\n 744307200000,\n 744393600000,\n 744480000000,\n 744566400000,\n 744825600000,\n 744912000000,\n 744998400000,\n 745084800000,\n 745171200000,\n 745430400000,\n 745516800000,\n 745603200000,\n 745689600000,\n 745776000000,\n 746035200000,\n 746121600000,\n 746208000000,\n 746294400000,\n 746380800000,\n 746640000000,\n 746726400000,\n 746812800000,\n 746899200000,\n 746985600000,\n 747244800000,\n 747331200000,\n 747417600000,\n 747504000000,\n 747590400000,\n 747849600000,\n 747936000000,\n 748022400000,\n 748108800000,\n 748195200000,\n 748454400000,\n 748540800000,\n 748627200000,\n 748713600000,\n 748800000000,\n 749059200000,\n 749145600000,\n 749232000000,\n 749318400000,\n 749664000000,\n 749750400000,\n 749836800000,\n 749923200000,\n 750009600000,\n 750268800000,\n 750355200000,\n 750441600000,\n 750528000000,\n 750614400000,\n 750873600000,\n 750960000000,\n 751046400000,\n 751132800000,\n 751219200000,\n 751478400000,\n 751564800000,\n 751651200000,\n 751737600000,\n 751824000000,\n 752083200000,\n 752169600000,\n 752256000000,\n 752342400000,\n 752428800000,\n 752688000000,\n 752774400000,\n 752860800000,\n 752947200000,\n 753033600000,\n 753292800000,\n 753379200000,\n 753465600000,\n 753552000000,\n 753638400000,\n 753897600000,\n 753984000000,\n 754070400000,\n 754156800000,\n 754243200000,\n 754502400000,\n 754588800000,\n 754675200000,\n 754761600000,\n 754848000000,\n 755107200000,\n 755193600000,\n 755280000000,\n 755366400000,\n 755452800000,\n 755712000000,\n 755798400000,\n 755884800000,\n 755971200000,\n 756057600000,\n 756316800000,\n 756403200000,\n 756489600000,\n 756576000000,\n 756662400000,\n 756921600000,\n 757008000000,\n 757094400000,\n 757180800000,\n 757267200000,\n 757526400000,\n 757612800000,\n 757699200000,\n 757785600000,\n 757872000000,\n 758131200000,\n 758217600000,\n 758304000000,\n 758390400000,\n 758476800000,\n 758736000000,\n 758822400000,\n 758908800000,\n 758995200000,\n 759081600000,\n 759340800000,\n 759427200000,\n 759513600000,\n 759600000000,\n 759686400000,\n 759945600000,\n 760032000000,\n 760118400000,\n 760204800000,\n 760291200000,\n 761155200000,\n 761241600000,\n 761328000000,\n 761414400000,\n 761500800000,\n 761760000000,\n 761846400000,\n 761932800000,\n 762019200000,\n 762105600000,\n 762364800000,\n 762451200000,\n 762537600000,\n 762624000000,\n 762710400000,\n 762969600000,\n 763056000000,\n 763142400000,\n 763228800000,\n 763315200000,\n 763574400000,\n 763660800000,\n 763747200000,\n 763833600000,\n 763920000000,\n 764179200000,\n 764265600000,\n 764352000000,\n 764438400000,\n 764524800000,\n 764784000000,\n 764870400000,\n 764956800000,\n 765043200000,\n 765129600000,\n 765388800000,\n 765475200000,\n 765561600000,\n 765648000000,\n 765734400000,\n 765993600000,\n 766080000000,\n 766166400000,\n 766252800000,\n 766339200000,\n 766598400000,\n 766684800000,\n 766771200000,\n 766857600000,\n 766944000000,\n 767203200000,\n 767289600000,\n 767376000000,\n 767462400000,\n 767548800000,\n 767894400000,\n 767980800000,\n 768067200000,\n 768153600000,\n 768412800000,\n 768499200000,\n 768585600000,\n 768672000000,\n 768758400000,\n 769017600000,\n 769104000000,\n 769190400000,\n 769276800000,\n 769363200000,\n 769622400000,\n 769708800000,\n 769795200000,\n 769881600000,\n 769968000000,\n 770227200000,\n 770313600000,\n 770400000000,\n 770486400000,\n 770572800000,\n 770832000000,\n 770918400000,\n 771004800000,\n 771091200000,\n 771177600000,\n 771436800000,\n 771523200000,\n 771609600000,\n 771696000000,\n 771782400000,\n 772041600000,\n 772128000000,\n 772214400000,\n 772300800000,\n 772387200000,\n 772646400000,\n 772732800000,\n 772819200000,\n 772905600000,\n 772992000000,\n 773251200000,\n 773337600000,\n 773424000000,\n 773510400000,\n 773596800000,\n 773856000000,\n 773942400000,\n 774028800000,\n 774115200000,\n 774201600000,\n 774460800000,\n 774547200000,\n 774633600000,\n 774720000000,\n 774806400000,\n 775065600000,\n 775152000000,\n 775238400000,\n 775324800000,\n 775411200000,\n 775670400000,\n 775756800000,\n 775843200000,\n 775929600000,\n 776016000000,\n 776275200000,\n 776361600000,\n 776448000000,\n 776534400000,\n 776620800000,\n 776880000000,\n 776966400000,\n 777052800000,\n 777139200000,\n 777225600000,\n 777484800000,\n 777571200000,\n 777657600000,\n 777744000000,\n 777830400000,\n 778089600000,\n 778176000000,\n 778262400000,\n 778348800000,\n 778435200000,\n 778694400000,\n 778780800000,\n 778867200000,\n 778953600000,\n 779040000000,\n 779299200000,\n 779385600000,\n 779472000000,\n 779558400000,\n 779644800000,\n 779904000000,\n 779990400000,\n 780076800000,\n 780163200000,\n 780249600000,\n 780508800000,\n 780595200000,\n 780681600000,\n 780768000000,\n 780854400000,\n 781286400000,\n 781372800000,\n 781459200000,\n 781718400000,\n 781804800000,\n 781891200000,\n 781977600000,\n 782064000000,\n 782323200000,\n 782409600000,\n 782496000000,\n 782582400000,\n 782668800000,\n 782928000000,\n 783014400000,\n 783100800000,\n 783187200000,\n 783273600000,\n 783532800000,\n 783619200000,\n 783705600000,\n 783792000000,\n 783878400000,\n 784137600000,\n 784224000000,\n 784310400000,\n 784396800000,\n 784483200000,\n 784742400000,\n 784828800000,\n 784915200000,\n 785001600000,\n 785088000000,\n 785347200000,\n 785433600000,\n 785520000000,\n 785606400000,\n 785692800000,\n 785952000000,\n 786038400000,\n 786124800000,\n 786211200000,\n 786297600000,\n 786556800000,\n ...]"
     },
     "execution_count": 109,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "xtdata.get_trading_dates('SZ', start_time='19910101', end_time='20230224', count=-1)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "获取版块列表"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 110,
   "outputs": [
    {
     "data": {
      "text/plain": "['上期所',\n '上证A股',\n '上证B股',\n '上证期权',\n '中金所',\n '创业板',\n '大商所',\n '板块加权指数',\n '板块指数',\n '沪市ETF',\n '沪市债券',\n '沪市基金',\n '沪市指数',\n '沪深A股',\n '沪深B股',\n '沪深ETF',\n '沪深债券',\n '沪深基金',\n '沪深指数',\n '深市ETF',\n '深市债券',\n '深市基金',\n '深市指数',\n '深证A股',\n '深证B股',\n '深证期权',\n '科创板',\n '科创板CDR',\n '证监会行业板块指数',\n '迅投一级行业板块加权指数',\n '迅投一级行业板块指数',\n '迅投三级行业板块加权指数',\n '迅投三级行业板块指数',\n '迅投二级行业板块加权指数',\n '迅投二级行业板块指数',\n '连续合约',\n '郑商所',\n '香港联交所指数',\n '香港联交所股票',\n 'SW1交通运输',\n 'SW1交通运输加权',\n 'SW1休闲服务',\n 'SW1休闲服务加权',\n 'SW1传媒',\n 'SW1传媒加权',\n 'SW1公用事业',\n 'SW1公用事业加权',\n 'SW1农林牧渔',\n 'SW1农林牧渔加权',\n 'SW1化工',\n 'SW1化工加权',\n 'SW1医药生物',\n 'SW1医药生物加权',\n 'SW1商业贸易',\n 'SW1商业贸易加权',\n 'SW1国防军工',\n 'SW1国防军工加权',\n 'SW1家用电器',\n 'SW1家用电器加权',\n 'SW1建筑材料',\n 'SW1建筑材料加权',\n 'SW1建筑装饰',\n 'SW1建筑装饰加权',\n 'SW1房地产',\n 'SW1房地产加权',\n 'SW1有色金属',\n 'SW1有色金属加权',\n 'SW1机械设备',\n 'SW1机械设备加权',\n 'SW1汽车',\n 'SW1汽车加权',\n 'SW1电子',\n 'SW1电子加权',\n 'SW1电气设备',\n 'SW1电气设备加权',\n 'SW1纺织服装',\n 'SW1纺织服装加权',\n 'SW1综合',\n 'SW1综合加权',\n 'SW1计算机',\n 'SW1计算机加权',\n 'SW1轻工制造',\n 'SW1轻工制造加权',\n 'SW1通信',\n 'SW1通信加权',\n 'SW1采掘',\n 'SW1采掘加权',\n 'SW1钢铁',\n 'SW1钢铁加权',\n 'SW1银行',\n 'SW1银行加权',\n 'SW1非银金融',\n 'SW1非银金融加权',\n 'SW1食品饮料',\n 'SW1食品饮料加权',\n 'SW2一般零售',\n 'SW2一般零售加权',\n 'SW2专业工程',\n 'SW2专业工程加权',\n 'SW2专业零售',\n 'SW2专业零售加权',\n 'SW2专用设备',\n 'SW2专用设备加权',\n 'SW2中药',\n 'SW2中药加权',\n 'SW2互联网传媒',\n 'SW2互联网传媒加权',\n 'SW2仪器仪表',\n 'SW2仪器仪表加权',\n 'SW2保险',\n 'SW2保险加权',\n 'SW2元件',\n 'SW2元件加权',\n 'SW2光学光电子',\n 'SW2光学光电子加权',\n 'SW2公交',\n 'SW2公交加权',\n 'SW2其他交运设备',\n 'SW2其他交运设备加权',\n 'SW2其他休闲服务',\n 'SW2其他休闲服务加权',\n 'SW2其他建材',\n 'SW2其他建材加权',\n 'SW2其他电子',\n 'SW2其他电子加权',\n 'SW2其他轻工制造',\n 'SW2其他轻工制造加权',\n 'SW2其他采掘',\n 'SW2其他采掘加权',\n 'SW2农业综合',\n 'SW2农业综合加权',\n 'SW2农产品加工',\n 'SW2农产品加工加权',\n 'SW2动物保健',\n 'SW2动物保健加权',\n 'SW2包装印刷',\n 'SW2包装印刷加权',\n 'SW2化学制品',\n 'SW2化学制品加权',\n 'SW2化学制药',\n 'SW2化学制药加权',\n 'SW2化学原料',\n 'SW2化学原料加权',\n 'SW2化学纤维',\n 'SW2化学纤维加权',\n 'SW2医疗器械',\n 'SW2医疗器械加权',\n 'SW2医疗服务',\n 'SW2医疗服务加权',\n 'SW2医药商业',\n 'SW2医药商业加权',\n 'SW2半导体',\n 'SW2半导体加权',\n 'SW2商业物业经营',\n 'SW2商业物业经营加权',\n 'SW2园区开发',\n 'SW2园区开发加权',\n 'SW2园林工程',\n 'SW2园林工程加权',\n 'SW2地面兵装',\n 'SW2地面兵装加权',\n 'SW2基础建设',\n 'SW2基础建设加权',\n 'SW2塑料',\n 'SW2塑料加权',\n 'SW2多元金融',\n 'SW2多元金融加权',\n 'SW2家用轻工',\n 'SW2家用轻工加权',\n 'SW2工业金属',\n 'SW2工业金属加权',\n 'SW2房地产开发',\n 'SW2房地产开发加权',\n 'SW2房屋建设',\n 'SW2房屋建设加权',\n 'SW2文化传媒',\n 'SW2文化传媒加权',\n 'SW2旅游综合',\n 'SW2旅游综合加权',\n 'SW2景点',\n 'SW2景点加权',\n 'SW2服装家纺',\n 'SW2服装家纺加权',\n 'SW2机场',\n 'SW2机场加权',\n 'SW2林业',\n 'SW2林业加权',\n 'SW2橡胶',\n 'SW2橡胶加权',\n 'SW2水务',\n 'SW2水务加权',\n 'SW2水泥制造',\n 'SW2水泥制造加权',\n 'SW2汽车整车',\n 'SW2汽车整车加权',\n 'SW2汽车服务',\n 'SW2汽车服务加权',\n 'SW2汽车零部件',\n 'SW2汽车零部件加权',\n 'SW2渔业',\n 'SW2渔业加权',\n 'SW2港口',\n 'SW2港口加权',\n 'SW2煤炭开采',\n 'SW2煤炭开采加权',\n 'SW2燃气',\n 'SW2燃气加权',\n 'SW2物流',\n 'SW2物流加权',\n 'SW2环保工程及服务',\n 'SW2环保工程及服务加权',\n 'SW2玻璃制造',\n 'SW2玻璃制造加权',\n 'SW2生物制品',\n 'SW2生物制品加权',\n 'SW2电力',\n 'SW2电力加权',\n 'SW2电子制造',\n 'SW2电子制造加权',\n 'SW2电机',\n 'SW2电机加权',\n 'SW2电气自动化设备',\n 'SW2电气自动化设备加权',\n 'SW2电源设备',\n 'SW2电源设备加权',\n 'SW2畜禽养殖',\n 'SW2畜禽养殖加权',\n 'SW2白色家电',\n 'SW2白色家电加权',\n 'SW2石油化工',\n 'SW2石油化工加权',\n 'SW2石油开采',\n 'SW2石油开采加权',\n 'SW2种植业',\n 'SW2种植业加权',\n 'SW2稀有金属',\n 'SW2稀有金属加权',\n 'SW2纺织制造',\n 'SW2纺织制造加权',\n 'SW2综合',\n 'SW2综合加权',\n 'SW2航天装备',\n 'SW2航天装备加权',\n 'SW2航空装备',\n 'SW2航空装备加权',\n 'SW2航空运输',\n 'SW2航空运输加权',\n 'SW2航运',\n 'SW2航运加权',\n 'SW2船舶制造',\n 'SW2船舶制造加权',\n 'SW2营销传播',\n 'SW2营销传播加权',\n 'SW2装修装饰',\n 'SW2装修装饰加权',\n 'SW2视听器材',\n 'SW2视听器材加权',\n 'SW2计算机应用',\n 'SW2计算机应用加权',\n 'SW2计算机设备',\n 'SW2计算机设备加权',\n 'SW2证券',\n 'SW2证券加权',\n 'SW2贸易',\n 'SW2贸易加权',\n 'SW2运输设备',\n 'SW2运输设备加权',\n 'SW2通信设备',\n 'SW2通信设备加权',\n 'SW2通信运营',\n 'SW2通信运营加权',\n 'SW2通用机械',\n 'SW2通用机械加权',\n 'SW2造纸',\n 'SW2造纸加权',\n 'SW2酒店',\n 'SW2酒店加权',\n 'SW2采掘服务',\n 'SW2采掘服务加权',\n 'SW2金属制品',\n 'SW2金属制品加权',\n 'SW2金属非金属新材料',\n 'SW2金属非金属新材料加权',\n 'SW2钢铁',\n 'SW2钢铁加权',\n 'SW2铁路运输',\n 'SW2铁路运输加权',\n 'SW2银行',\n 'SW2银行加权',\n 'SW2食品加工',\n 'SW2食品加工加权',\n 'SW2餐饮',\n 'SW2餐饮加权',\n 'SW2饮料制造',\n 'SW2饮料制造加权',\n 'SW2饲料',\n 'SW2饲料加权',\n 'SW2高低压设备',\n 'SW2高低压设备加权',\n 'SW2高速公路',\n 'SW2高速公路加权',\n 'SW2黄金',\n 'SW2黄金加权',\n 'SW3IT服务',\n 'SW3IT服务加权',\n 'SW3LED',\n 'SW3LED加权',\n 'SW3一般物业经营',\n 'SW3一般物业经营加权',\n 'SW3专业市场',\n 'SW3专业市场加权',\n 'SW3专业连锁',\n 'SW3专业连锁加权',\n 'SW3丝绸',\n 'SW3丝绸加权',\n 'SW3中压设备',\n 'SW3中压设备加权',\n 'SW3中药',\n 'SW3中药加权',\n 'SW3乘用车',\n 'SW3乘用车加权',\n 'SW3乳品',\n 'SW3乳品加权',\n 'SW3互联网信息服务',\n 'SW3互联网信息服务加权',\n 'SW3人工景点',\n 'SW3人工景点加权',\n 'SW3仪器仪表',\n 'SW3仪器仪表加权',\n 'SW3休闲服装',\n 'SW3休闲服装加权',\n 'SW3低压设备',\n 'SW3低压设备加权',\n 'SW3保险',\n 'SW3保险加权',\n 'SW3储能设备',\n 'SW3储能设备加权',\n 'SW3光伏设备',\n 'SW3光伏设备加权',\n 'SW3光学元件',\n 'SW3光学元件加权',\n 'SW3公交',\n 'SW3公交加权',\n 'SW3其他专业工程',\n 'SW3其他专业工程加权',\n 'SW3其他互联网服务',\n 'SW3其他互联网服务加权',\n 'SW3其他交运设备',\n 'SW3其他交运设备加权',\n 'SW3其他休闲服务',\n 'SW3其他休闲服务加权',\n 'SW3其他农产品加工',\n 'SW3其他农产品加工加权',\n 'SW3其他化学制品',\n 'SW3其他化学制品加权',\n 'SW3其他化学原料',\n 'SW3其他化学原料加权',\n 'SW3其他基础建设',\n 'SW3其他基础建设加权',\n 'SW3其他塑料制品',\n 'SW3其他塑料制品加权',\n 'SW3其他家用轻工',\n 'SW3其他家用轻工加权',\n 'SW3其他建材',\n 'SW3其他建材加权',\n 'SW3其他文化传媒',\n 'SW3其他文化传媒加权',\n 'SW3其他服装',\n 'SW3其他服装加权',\n 'SW3其他橡胶制品',\n 'SW3其他橡胶制品加权',\n 'SW3其他电子',\n 'SW3其他电子加权',\n 'SW3其他种植业',\n 'SW3其他种植业加权',\n 'SW3其他稀有小金属',\n 'SW3其他稀有小金属加权',\n 'SW3其他纤维',\n 'SW3其他纤维加权',\n 'SW3其他纺织',\n 'SW3其他纺织加权',\n 'SW3其他轻工制造',\n 'SW3其他轻工制造加权',\n 'SW3其他酒类',\n 'SW3其他酒类加权',\n 'SW3其他采掘',\n 'SW3其他采掘加权',\n 'SW3其他采掘服务',\n 'SW3其他采掘服务加权',\n 'SW3其它专用机械',\n 'SW3其它专用机械加权',\n 'SW3其它电源设备',\n 'SW3其它电源设备加权',\n 'SW3其它视听器材',\n 'SW3其它视听器材加权',\n 'SW3其它通用机械',\n 'SW3其它通用机械加权',\n 'SW3内燃机',\n 'SW3内燃机加权',\n 'SW3农业综合',\n 'SW3农业综合加权',\n 'SW3农用机械',\n 'SW3农用机械加权',\n 'SW3农药',\n 'SW3农药加权',\n 'SW3冰箱',\n 'SW3冰箱加权',\n 'SW3冶金矿采化工设备',\n 'SW3冶金矿采化工设备加权',\n 'SW3分立器件',\n 'SW3分立器件加权',\n 'SW3制冷空调设备',\n 'SW3制冷空调设备加权',\n 'SW3动物保健',\n 'SW3动物保健加权',\n 'SW3包装印刷',\n 'SW3包装印刷加权',\n 'SW3化学制剂',\n 'SW3化学制剂加权',\n 'SW3化学原料药',\n 'SW3化学原料药加权',\n 'SW3化学工程',\n 'SW3化学工程加权',\n 'SW3医疗器械',\n 'SW3医疗器械加权',\n 'SW3医疗服务',\n 'SW3医疗服务加权',\n 'SW3医药商业',\n 'SW3医药商业加权',\n 'SW3半导体材料',\n 'SW3半导体材料加权',\n 'SW3印制电路板',\n 'SW3印制电路板加权',\n 'SW3印刷包装机械',\n 'SW3印刷包装机械加权',\n 'SW3印染',\n 'SW3印染加权',\n 'SW3合成革',\n 'SW3合成革加权',\n 'SW3商用载客车',\n 'SW3商用载客车加权',\n 'SW3商用载货车',\n 'SW3商用载货车加权',\n 'SW3啤酒',\n 'SW3啤酒加权',\n 'SW3园区开发',\n 'SW3园区开发加权',\n 'SW3园林工程',\n 'SW3园林工程加权',\n 'SW3国际工程承包',\n 'SW3国际工程承包加权',\n 'SW3地面兵装',\n 'SW3地面兵装加权',\n 'SW3城轨建设',\n 'SW3城轨建设加权',\n 'SW3复合肥',\n 'SW3复合肥加权',\n 'SW3多业态零售',\n 'SW3多业态零售加权',\n 'SW3多元金融',\n 'SW3多元金融加权',\n 'SW3女装',\n 'SW3女装加权',\n 'SW3家具',\n 'SW3家具加权',\n 'SW3家电零部件',\n 'SW3家电零部件加权',\n 'SW3家纺',\n 'SW3家纺加权',\n 'SW3小家电',\n 'SW3小家电加权',\n 'SW3工控自动化',\n 'SW3工控自动化加权',\n 'SW3工程机械',\n 'SW3工程机械加权',\n 'SW3平面媒体',\n 'SW3平面媒体加权',\n 'SW3彩电',\n 'SW3彩电加权',\n 'SW3影视动漫',\n 'SW3影视动漫加权',\n 'SW3房地产开发',\n 'SW3房地产开发加权',\n 'SW3房屋建设',\n 'SW3房屋建设加权',\n 'SW3改性塑料',\n 'SW3改性塑料加权',\n 'SW3文娱用品',\n 'SW3文娱用品加权',\n 'SW3新能源发电',\n 'SW3新能源发电加权',\n 'SW3旅游综合',\n 'SW3旅游综合加权',\n 'SW3无机盐',\n 'SW3无机盐加权',\n 'SW3日用化学产品',\n 'SW3日用化学产品加权',\n 'SW3显示器件',\n 'SW3显示器件加权',\n 'SW3普钢',\n 'SW3普钢加权',\n 'SW3有线电视网络',\n 'SW3有线电视网络加权',\n 'SW3机场',\n 'SW3机场加权',\n 'SW3机床工具',\n 'SW3机床工具加权',\n 'SW3机械基础件',\n 'SW3机械基础件加权',\n 'SW3林业',\n 'SW3林业加权',\n 'SW3果蔬加工',\n 'SW3果蔬加工加权',\n 'SW3棉纺',\n 'SW3棉纺加权',\n 'SW3楼宇设备',\n 'SW3楼宇设备加权',\n 'SW3毛纺',\n 'SW3毛纺加权',\n 'SW3民爆用品',\n 'SW3民爆用品加权',\n 'SW3氟化工及制冷剂',\n 'SW3氟化工及制冷剂加权',\n 'SW3氨纶',\n 'SW3氨纶加权',\n 'SW3氮肥',\n 'SW3氮肥加权',\n 'SW3氯碱',\n 'SW3氯碱加权',\n 'SW3水产养殖',\n 'SW3水产养殖加权',\n 'SW3水利工程',\n 'SW3水利工程加权',\n 'SW3水务',\n 'SW3水务加权',\n 'SW3水泥制造',\n 'SW3水泥制造加权',\n 'SW3水电',\n 'SW3水电加权',\n 'SW3汽车服务',\n 'SW3汽车服务加权',\n 'SW3汽车零部件',\n 'SW3汽车零部件加权',\n 'SW3油气钻采服务',\n 'SW3油气钻采服务加权',\n 'SW3洗衣机',\n 'SW3洗衣机加权',\n 'SW3海洋捕捞',\n 'SW3海洋捕捞加权',\n 'SW3涂料油漆油墨制造',\n 'SW3涂料油漆油墨制造加权',\n 'SW3涤纶',\n 'SW3涤纶加权',\n 'SW3港口',\n 'SW3港口加权',\n 'SW3火电',\n 'SW3火电加权',\n 'SW3火电设备',\n 'SW3火电设备加权',\n 'SW3炭黑',\n 'SW3炭黑加权',\n 'SW3热电',\n 'SW3热电加权',\n 'SW3焦炭加工',\n 'SW3焦炭加工加权',\n 'SW3煤炭开采',\n 'SW3煤炭开采加权',\n 'SW3燃机发电',\n 'SW3燃机发电加权',\n 'SW3燃气',\n 'SW3燃气加权',\n 'SW3物流',\n 'SW3物流加权',\n 'SW3特钢',\n 'SW3特钢加权',\n 'SW3环保工程及服务',\n 'SW3环保工程及服务加权',\n 'SW3环保设备',\n 'SW3环保设备加权',\n 'SW3玻璃制造',\n 'SW3玻璃制造加权',\n 'SW3玻纤',\n 'SW3玻纤加权',\n 'SW3珠宝首饰',\n 'SW3珠宝首饰加权',\n 'SW3生物制品',\n 'SW3生物制品加权',\n 'SW3电子系统组装',\n 'SW3电子系统组装加权',\n 'SW3电子零部件制造',\n 'SW3电子零部件制造加权',\n 'SW3电机',\n 'SW3电机加权',\n 'SW3电网自动化',\n 'SW3电网自动化加权',\n 'SW3男装',\n 'SW3男装加权',\n 'SW3畜禽养殖',\n 'SW3畜禽养殖加权',\n 'SW3白酒',\n 'SW3白酒加权',\n 'SW3百货',\n 'SW3百货加权',\n 'SW3石油加工',\n 'SW3石油加工加权',\n 'SW3石油开采',\n 'SW3石油开采加权',\n 'SW3石油贸易',\n 'SW3石油贸易加权',\n 'SW3磁性材料',\n 'SW3磁性材料加权',\n 'SW3磨具磨料',\n 'SW3磨具磨料加权',\n 'SW3磷化工及磷酸盐',\n 'SW3磷化工及磷酸盐加权',\n 'SW3磷肥',\n 'SW3磷肥加权',\n 'SW3种子生产',\n 'SW3种子生产加权',\n 'SW3移动互联网服务',\n 'SW3移动互联网服务加权',\n 'SW3稀土',\n 'SW3稀土加权',\n 'SW3空调',\n 'SW3空调加权',\n 'SW3管材',\n 'SW3管材加权',\n 'SW3粘胶',\n 'SW3粘胶加权',\n 'SW3粮油加工',\n 'SW3粮油加工加权',\n 'SW3粮食种植',\n 'SW3粮食种植加权',\n 'SW3纯碱',\n 'SW3纯碱加权',\n 'SW3纺织化学用品',\n 'SW3纺织化学用品加权',\n 'SW3纺织服装设备',\n 'SW3纺织服装设备加权',\n 'SW3线缆部件及其他',\n 'SW3线缆部件及其他加权',\n 'SW3终端设备',\n 'SW3终端设备加权',\n 'SW3维纶',\n 'SW3维纶加权',\n 'SW3综合',\n 'SW3综合加权',\n 'SW3综合电力设备商',\n 'SW3综合电力设备商加权',\n 'SW3耐火材料',\n 'SW3耐火材料加权',\n 'SW3聚氨酯',\n 'SW3聚氨酯加权',\n 'SW3肉制品',\n 'SW3肉制品加权',\n 'SW3自然景点',\n 'SW3自然景点加权',\n 'SW3航天装备',\n 'SW3航天装备加权',\n 'SW3航空装备',\n 'SW3航空装备加权',\n 'SW3航空运输',\n 'SW3航空运输加权',\n 'SW3航运',\n 'SW3航运加权',\n 'SW3船舶制造',\n 'SW3船舶制造加权',\n 'SW3营销服务',\n 'SW3营销服务加权',\n 'SW3葡萄酒',\n 'SW3葡萄酒加权',\n 'SW3被动元件',\n 'SW3被动元件加权',\n 'SW3装修装饰',\n 'SW3装修装饰加权',\n 'SW3计算机设备',\n 'SW3计算机设备加权',\n 'SW3计量仪表',\n 'SW3计量仪表加权',\n 'SW3证券',\n 'SW3证券加权',\n 'SW3调味发酵品',\n 'SW3调味发酵品加权',\n 'SW3贸易',\n 'SW3贸易加权',\n 'SW3超市',\n 'SW3超市加权',\n 'SW3路桥施工',\n 'SW3路桥施工加权',\n 'SW3轮胎',\n 'SW3轮胎加权',\n 'SW3软件开发',\n 'SW3软件开发加权',\n 'SW3软饮料',\n 'SW3软饮料加权',\n 'SW3辅料',\n 'SW3辅料加权',\n 'SW3通信传输设备',\n 'SW3通信传输设备加权',\n 'SW3通信运营',\n 'SW3通信运营加权',\n 'SW3通信配套服务',\n 'SW3通信配套服务加权',\n 'SW3造纸',\n 'SW3造纸加权',\n 'SW3酒店',\n 'SW3酒店加权',\n 'SW3重型机械',\n 'SW3重型机械加权',\n 'SW3金属制品',\n 'SW3金属制品加权',\n 'SW3金属新材料',\n 'SW3金属新材料加权',\n 'SW3钢结构',\n 'SW3钢结构加权',\n 'SW3钨',\n 'SW3钨加权',\n 'SW3钾肥',\n 'SW3钾肥加权',\n 'SW3铁路建设',\n 'SW3铁路建设加权',\n 'SW3铁路设备',\n 'SW3铁路设备加权',\n 'SW3铁路运输',\n 'SW3铁路运输加权',\n 'SW3铅锌',\n 'SW3铅锌加权',\n 'SW3铜',\n 'SW3铜加权',\n 'SW3铝',\n 'SW3铝加权',\n 'SW3银行',\n 'SW3银行加权',\n 'SW3锂',\n 'SW3锂加权',\n 'SW3集成电路',\n 'SW3集成电路加权',\n 'SW3非金属新材料',\n 'SW3非金属新材料加权',\n 'SW3鞋帽',\n 'SW3鞋帽加权',\n 'SW3风电设备',\n 'SW3风电设备加权',\n 'SW3食品综合',\n 'SW3食品综合加权',\n 'SW3餐饮',\n 'SW3餐饮加权',\n 'SW3饲料',\n 'SW3饲料加权',\n 'SW3高压设备',\n 'SW3高压设备加权',\n 'SW3高速公路',\n 'SW3高速公路加权',\n 'SW3黄酒',\n 'SW3黄酒加权',\n 'SW3黄金',\n 'SW3黄金加权',\n 'CSRC1交通运输、仓储和邮政业',\n 'CSRC1住宿和餐饮业',\n 'CSRC1信息传输、软件和信息技术服务业',\n 'CSRC1农、林、牧、渔业',\n 'CSRC1制造业',\n 'CSRC1卫生和社会工作',\n 'CSRC1居民服务、修理和其他服务业',\n 'CSRC1建筑业',\n 'CSRC1房地产业',\n 'CSRC1批发和零售业',\n 'CSRC1教育',\n 'CSRC1文化、体育和娱乐业',\n 'CSRC1水利、环境和公共设施管理业',\n 'CSRC1电力、热力、燃气及水生产和供应业',\n 'CSRC1科学研究和技术服务业',\n 'CSRC1租赁和商务服务业',\n 'CSRC1综合',\n 'CSRC1采矿业',\n 'CSRC1金融业',\n 'CSRC2专业技术服务业',\n 'CSRC2专用设备制造业',\n 'CSRC2互联网和相关服务',\n 'CSRC2仓储业',\n 'CSRC2仪器仪表制造业',\n 'CSRC2住宿业',\n 'CSRC2体育',\n 'CSRC2保险业',\n 'CSRC2公共设施管理业',\n 'CSRC2其他制造业',\n 'CSRC2其他金融业',\n 'CSRC2农、林、牧、渔服务业',\n 'CSRC2农业',\n 'CSRC2农副食品加工业',\n 'CSRC2化学原料及化学制品制造业',\n 'CSRC2化学纤维制造业',\n 'CSRC2医药制造业',\n 'CSRC2卫生',\n 'CSRC2印刷和记录媒介复制业',\n 'CSRC2商务服务业',\n 'CSRC2土木工程建筑业',\n 'CSRC2家具制造业',\n 'CSRC2广播、电视、电影和影视录音制作业',\n 'CSRC2废弃资源综合利用业',\n 'CSRC2建筑安装业',\n 'CSRC2建筑装饰和其他建筑业',\n 'CSRC2开采辅助活动',\n 'CSRC2房地产业',\n 'CSRC2房屋建筑业',\n 'CSRC2批发业',\n 'CSRC2教育',\n 'CSRC2文化艺术业',\n 'CSRC2文教、工美、体育和娱乐用品制造业',\n 'CSRC2新闻和出版业',\n 'CSRC2有色金属冶炼及压延加工业',\n 'CSRC2有色金属矿采选业',\n 'CSRC2木材加工及木、竹、藤、棕、草制品业',\n 'CSRC2机动车、电子产品和日用产品修理业',\n 'CSRC2林业',\n 'CSRC2橡胶和塑料制品业',\n 'CSRC2水上运输业',\n 'CSRC2水的生产和供应业',\n 'CSRC2汽车制造业',\n 'CSRC2渔业',\n 'CSRC2煤炭开采和洗选业',\n 'CSRC2燃气生产和供应业',\n 'CSRC2生态保护和环境治理业',\n 'CSRC2电信、广播电视和卫星传输服务',\n 'CSRC2电力、热力生产和供应业',\n 'CSRC2电气机械及器材制造业',\n 'CSRC2畜牧业',\n 'CSRC2皮革、毛皮、羽毛及其制品和制鞋业',\n 'CSRC2石油加工、炼焦及核燃料加工业',\n 'CSRC2石油和天然气开采业',\n 'CSRC2研究和试验发展',\n 'CSRC2科技推广和应用服务业',\n 'CSRC2租赁业',\n 'CSRC2纺织业',\n 'CSRC2纺织服装、服饰业',\n 'CSRC2综合',\n 'CSRC2航空运输业',\n 'CSRC2装卸搬运和运输代理业',\n 'CSRC2计算机、通信和其他电子设备制造业',\n 'CSRC2货币金融服务',\n 'CSRC2资本市场服务',\n 'CSRC2软件和信息技术服务业',\n 'CSRC2通用设备制造业',\n 'CSRC2造纸及纸制品业',\n 'CSRC2道路运输业',\n 'CSRC2邮政业',\n 'CSRC2酒、饮料和精制茶制造业',\n 'CSRC2金属制品业',\n 'CSRC2铁路、船舶、航空航天和其它运输设备制造业',\n 'CSRC2铁路运输业',\n 'CSRC2零售业',\n 'CSRC2非金属矿物制品业',\n 'CSRC2非金属矿采选业',\n 'CSRC2食品制造业',\n 'CSRC2餐饮业',\n 'CSRC2黑色金属冶炼及压延加工业',\n 'CSRC2黑色金属矿采选业']"
     },
     "execution_count": 110,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "sector_list = xtdata.get_sector_list()\n",
    "sector_list"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "板块成分股列表"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 111,
   "outputs": [
    {
     "data": {
      "text/plain": "['000569.SZ',\n '000708.SZ',\n '000709.SZ',\n '000717.SZ',\n '000761.SZ',\n '000825.SZ',\n '000898.SZ',\n '000932.SZ',\n '000959.SZ',\n '002075.SZ',\n '002110.SZ',\n '002756.SZ',\n '600001.SH',\n '600005.SH',\n '600010.SH',\n '600019.SH',\n '600022.SH',\n '600102.SH',\n '600117.SH',\n '600126.SH',\n '600231.SH',\n '600282.SH',\n '600295.SH',\n '600307.SH',\n '600357.SH',\n '600399.SH',\n '600408.SH',\n '600507.SH',\n '600569.SH',\n '600581.SH',\n '600608.SH',\n '600782.SH',\n '600808.SH',\n '601003.SH',\n '601005.SH',\n '603878.SH',\n '603995.SH']"
     },
     "execution_count": 111,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "\n",
    "stock_list_in_sector = xtdata.get_stock_list_in_sector('CSRC2黑色金属冶炼及压延加工业')\n",
    "stock_list_in_sector"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "下载板块分类信息"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 112,
   "outputs": [],
   "source": [
    "is_done = xtdata.download_sector_data()\n",
    "is_done"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "添加自定义板块"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 113,
   "outputs": [],
   "source": [
    "xtdata.add_sector('测试版块', stock_list_in_sector)"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "markdown",
   "source": [
    "移除自定义板块"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 114,
   "outputs": [],
   "source": [
    "xtdata.remove_sector('测试版块')"
   ],
   "metadata": {
    "collapsed": false
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
